<?php
/**
 * 公用基础类，实现页面的输出
 * @authors wangkang (wangkang@myhexin.com)
 * @date    2016-06-06 13:58:28
 * @version $Id$
 */

class Base
{
    static private $_data = array();
    static private $_action = 'index';
    static function getHtmlContent($file, $data)
    {
        $html = '';
        ob_start();
        include ($file);
        $html = ob_get_contents();
        ob_flush();
        flush();
        ob_end_clean();
    }

    static function getHtmlFile($action, $view)
    {
        return APP_PATH."views/{$view}/{$action}.phtml";
    }

    static function display($action, $view)
    {
        // echo $action."-+-".$view;exit;
        self::getHtmlContent(self::getHtmlFile($action, $view), self::$_data);
    }

    static function assign($name, $value, $action)
    {
        if (self::$_action != $action) {
            self::$_action = $action;
            self::$_data = array();
        }
        self::$_data[$name] = $value;
    }
}
